package com.example.client_group5;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

public class UserManager {
	private SharedPreferences preferences;
	private String avatarLink;
	private String user_id;
	private String fullname;
	private String username;
	private String password;
	private String bio;
	private String web;
	private String location;
	public UserManager(Context context, String namePreferences){
		preferences = context.getSharedPreferences(namePreferences, Activity.MODE_PRIVATE);
	}
	public void saveAvatar(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getAvatar(String key, String defValue){
		avatarLink = preferences.getString(key, defValue);
		return avatarLink;
	}
	public void saveUserId(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getUserId(String key, String defValue){
		user_id = preferences.getString(key, defValue);
		return user_id;
	}
	public void saveFullName(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getFullName(String key, String defValue){
		fullname = preferences.getString(key, defValue);
		return fullname;
	}
	public void saveUserName(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getUserName(String key, String defValue){
		username = preferences.getString(key, defValue);
		return username;
	}
	public void savePassword(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getPassword(String key, String defValue){
		password = preferences.getString(key, defValue);
		return password;
	}
	
	public void saveBio(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getBio(String key, String defValue){
		bio = preferences.getString(key, defValue);
		return bio;
	}
	
	public void saveWeb(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getWeb(String key, String defValue){
		web = preferences.getString(key, defValue);
		return web;
	}
	
	
	public void saveLocation(String key, String value){
		SharedPreferences.Editor edit = preferences.edit();
		edit.putString(key, value);
		edit.commit();
	}
	public String getLocation(String key, String defValue){
		location = preferences.getString(key, defValue);
		return location;
	}
	public void removeUser(){
		saveAvatar("avatar", "");
		saveFullName("fullname", "");
		saveUserName("username", "");
		saveUserId("userId", "");
		saveBio("bio", "");
		saveLocation("location", "");
		saveWeb("web", "");
	}
	
}
